package model;

public class Arete {
	
	private Carrefour carDepart;
	private Carrefour carArrivee;
	private int vitesseMax;
	private int capaciteMax;
	private int capaciteActuel;
	private int distance;
	private int [] portionDeRoute;
	private Feu feu;
	private int xDeb;
	private int xFin;
	private int yDeb;
	private int yFin;
	
	public Arete(Carrefour carDepart, Carrefour carArrivee, int vitesseMax,
			int capaciteMax, int distance, Feu feu, int xDeb, int xFin,int yDeb,int yFin) {
		super();
		this.carDepart = carDepart;
		this.carArrivee = carArrivee;
		this.vitesseMax = vitesseMax;
		this.capaciteMax = capaciteMax;
		this.distance = distance;
		this.capaciteActuel = 0;
		this.setPortionDeRoute(new int [distance]);
		this.feu = feu;
		this.xDeb=xDeb;
		this.yDeb=yDeb;
		this.xFin=xFin;
		this.yFin=yFin;
		feu.start();
		
		carDepart.addRoute(this);
	}
	
	
	public int getxDeb() {
		return xDeb;
	}


	public void setxDeb(int xDeb) {
		this.xDeb = xDeb;
	}


	public int getxFin() {
		return xFin;
	}


	public void setxFin(int xFin) {
		this.xFin = xFin;
	}


	public int getyDeb() {
		return yDeb;
	}


	public void setyDeb(int yDeb) {
		this.yDeb = yDeb;
	}


	public int getyFin() {
		return yFin;
	}


	public void setyFin(int yFin) {
		this.yFin = yFin;
	}


	public Carrefour getCarDepart() {
		return carDepart;
	}


	public void setCarDepart(Carrefour carDepart) {
		this.carDepart = carDepart;
	}


	public Carrefour getCarArrivee() {
		return carArrivee;
	}


	public void setCarArrivee(Carrefour carArrivee) {
		this.carArrivee = carArrivee;
	}


	public int getVitesseMax() {
		return vitesseMax;
	}


	public void setVitesseMax(int vitesseMax) {
		this.vitesseMax = vitesseMax;
	}


	public int getCapaciteMax() {
		return capaciteMax;
	}


	public void setCapaciteMax(int capaciteMax) {
		this.capaciteMax = capaciteMax;
	}
	
	public int getDistance() {
		return distance;
	}


	public void setDistance(int distance) {
		this.distance = distance;
	}


	public int getCapaciteActuel() {
		return capaciteActuel;
	}

	/**
	 * 
	 * @return false si la route est pleine, sinon return true et incr�mente capciteActuel
	 */
	public boolean nouvelleVoiture(){
		if(this.getCapaciteActuel()==this.getCapaciteMax()) return false;
		capaciteActuel++;
		return true;
	}
	
	/**
	 * Enleve une voiture de la route
	 */
	public void departVoiture(){
		capaciteActuel--;
	}
	
	public String toString(){
		return "Route au d�part du carrefour n� " + this.carDepart.toString() + " et arrivan au carrefour n� " + this.carArrivee.toString();
	}


	public int [] getPortionDeRoute() {
		return portionDeRoute;
	}


	public void setPortionDeRoute(int [] portionDeRoute) {
		this.portionDeRoute = portionDeRoute;
	}
	

	public Feu getFeu()
	{
		return this.feu;
	}

	

}
